#coding:utf-8
"""Copyright (c) 2022 God Forever
Online-class Efficiency Optimizer is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
         http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details."""
from multiprocessing import Process,Queue
import psutil
import os
import time
from tkinter.messagebox import *
import win32api
from win32process import *
import keyboard
from win32gui import *
import sys
filename=os.getcwd()
a=filename+"/"
b=a+"网课效率优化器/网课效率优化器-禁用"
b=b.replace("/","\\")
os.chdir(r"{}".format(b))
os.popen(r"网课效率优化器-禁用.pyw")
b=a+"网课效率优化器/网课效率优化器-限制"
b=b.replace("/","\\")
os.chdir(r"{}".format(b))
os.popen(r"网课效率优化器-限制.pyw")
showinfo('提示', '按下Shift+Ctrl+Alt+Delete关闭本程序')
downshift=0
downalt=0
downdelete=0
downctrl=0
from pynput.keyboard import Key, Listener
def on_press(key):
    global downshift, downalt, downdelete, downctrl, aaa2
    if key == Key.shift:
        downshift = 1
    if key == Key.ctrl_l:
        downctrl = 1
    if key == Key.alt_l:
        downalt = 1
    if key == Key.delete:
        downdelete = 1
    if downalt==1 and downshift==1 and downalt==1 and downdelete==1:
        downshift = 0
        downctrl = 0
        downalt = 0
        downdelete = 0
        from tkinter.messagebox import INFO
        closeit = askokcancel('提示', '确定要关闭程序吗？', icon=INFO)
        if closeit:
            for i in psutil.process_iter():
                if i.name()=='pyw.exe' or i.name()=='pyw.exe':
                    if not i.pid==os.getpid():
                        i.kill()
            psutil.Process(os.getpid()).kill()
def on_release(key):
    global downshift, downalt, downdelete, downctrl
    if key == Key.shift:
        downshift = 0
    if key == Key.ctrl_l:
        downctrl = 0
    if key == Key.alt_l:
        downalt = 0
    if key == Key.delete:
        downdelete = 0
with Listener(on_press=on_press,on_release=on_release) as Listener:
    Listener.join()